[convert the strings to base64]
$ echo -n 'admin' | base64
YWRtaW4=
$ echo -n '1f2d1e2e67df' | base64
MWYyZDFlMmU2N2Rm

[Create the Secret]
$ kubectl apply -f ./Secret_1.yml
secret/mysecret created
$ kubectl apply -f ./Secret_2.yaml
secret/mysecret created

$ kubectl get secret mysecret -o yaml
apiVersion: v1
data:
  config.yaml: YXBpVXJsOiAiaHR0cHM6Ly9teS5hcGkuY29tL2FwaS92MSIKdXNlcm5hbWU6IHt7dXNlcm5hbWV9fQpwYXNzd29yZDoge3twYXNzd29yZH19
kind: Secret
metadata:
  creationTimestamp: 2018-11-15T20:40:59Z
  name: mysecret
  namespace: default
  resourceVersion: "7225"
  uid: c280ad2e-e916-11e8-98f2-025000000001
type: Opaque

[Edit a Secret]
To edit the data in the Secret, created using a manifest, modify the 'data' or 'stringData' field in manifest and apply the file to the cluster.
For example, if want to change the password, encode the new password string.

$ echo -n 'birdsarentreal' | base64
YmlyZHNhcmVudHJlYWw=

Now change the password from "MWYyZDFlMmU2N2Rm" to "YmlyZHNhcmVudHJlYWw=" in mysecret secret.

$ kubectl edit secret mysecret
apiVersion: v1
data:
  password: MWYyZDFlMmU2N2Rm                 ---->>> YmlyZHNhcmVudHJlYWw=
  username: YWRtaW4=
kind: Secret
metadata:
  annotations:
    kubectl.kubernetes.io/last-applied-configuration: |
      {"apiVersion":"v1","data":{"password":"MWYyZDFlMmU2N2Rm","username":"YWRtaW4="},"kind":"Secret","metadata":{"annotations":{},"name":"mysecret","namespace":"default"},"type":"Opaque"}
  creationTimestamp: "2024-06-02T09:30:04Z"
  name: mysecret
  namespace: default
  resourceVersion: "41128"
  uid: a66cc5d0-0b8f-4d70-97e4-a611ea3ed6d5
type: Opaque

Now save and close the file from editor.

[Create the Secret]
Now update the password using with YAML file.
$ kubectl apply -f ./Secret_4.yaml
secret/mysecret configured

[delete the Secret]
$ kubectl delete secret mysecret



LINK :- https://kubernetes.io/docs/tasks/configmap-secret/managing-secret-using-config-file/
